home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-06 | 6.8 KB | 254 lines | [TEXT/KAHL] |
- /******************************************************************************
- CApp.cp
-
- My Application Class
-
- Copyright © 1995 Dan Crevier. All rights reserved.
-
- Generated by Visual Architectâ„¢ 9:19 AM Mon, Nov 6, 1995
-
- This file is only generated once. You can modify it by filling
- in the placeholder methods and adding any new methods you wish.
-
- If you change the name of the application, a fresh version of this
- file will be generated. If you have made any changes to the file
- with the old name, you will have to copy those changes to the new
- file by hand.
-
- ******************************************************************************/
-
- #include "CApp.h"
-
- #include <CDialog.h>
- #include <TCLForceReferences.h>
- #include <CBartender.h>
-
- //#include "AppCommands.h" // Remove comments if DoCommand overridden
-
- #include "CWASTEText.h"
- #include "CWASTEDlgText.h"
-
- #ifndef __SCRIPT__
- #include <Script.h>
- #endif
-
- #include "CTSMSwitchboard.h"
- #include "CTSMDesktop.h"
-
- #include <Drag.h>
-
- static Boolean DragAndDropAvailable(void);
- Boolean gHasDragAndDrop = false;
-
- static Boolean TSMAvailable(void);
-
- extern CDesktop *gDesktop;
- extern CBartender *gBartender;
-
- short gUsingTSM = false;
-
- TCL_DEFINE_CLASS_M1(CApp, x_CApp);
-
- /**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
-
- /******************************************************************************
- CApp
-
- Constructor added by Dan Crevier
-
- ******************************************************************************/
-
- CApp::CApp(void)
- {
- gUsingTSM = TSMAvailable() && (InitTSMAwareApplication()==noErr);
-
- gHasDragAndDrop = DragAndDropAvailable();
- }
-
- /******************************************************************************
- ICApp
-
- Initialize an Application.
-
- ******************************************************************************/
-
- void CApp::ICApp()
-
- {
- // The values below are:
- //
- // extraMasters - The number of additional master pointer blocks
- // to be allocated.
- // aRainyDayFund - The total amount of reserved memory. When
- // allocation digs into the rainy day fund, the
- // user is notified that memory is low. Set this
- // value to the sum of aCriticalBalance plus
- // aToolboxBalance plus a fudge for user warning.
- // aCriticalBalance - The part of the rainy day fund reserved for
- // critical operations, like Save or Quit. Set
- // this value to the memory needed for the largest
- // possible Save plus aToolboxBalance. This
- // memory will only be used if SetCriticalOperation()
- // is set TRUE or if RequestMemory()/SetAllocation()
- // is set FALSE (kAllocCantFail).
- // aToolboxBalance - The part of the rainy day fund reserved for
- // ToolBox bozos that bomb if a memory request fails.
- // This memory is used unless RequestMemory()/
- // SetAllocation() is set TRUE (kAllocCanFail).
- // Almost all TCL memory allocation is done with
- // kAllocCanFail, and yours should be, too. The
- // default 2K is probably enough.
-
- Ix_CApp(4, 24000L, 20480L, 2048L);
-
- // Initialize your own application data here.
-
- }
-
-
- /******************************************************************************
- ~CApp
-
- Destruct an Application.
-
- ******************************************************************************/
-
- CApp::~CApp()
- {
- if (gUsingTSM) CloseTSMAwareApplication();
- }
-
- /******************************************************************************
- ForceClassReferences {OVERRIDE}
-
- Reference classes that do object I/O or are created only
- by new_by_name.
- ******************************************************************************/
-
- void CApp::ForceClassReferences(void)
-
- {
- x_CApp::ForceClassReferences();
-
- // Insert your own class references here
- // by calling TCL_FORCE_REFERENCE for each class
- // See x_CApp.cp
-
- TCL_FORCE_REFERENCE(CWASTEText);
- TCL_FORCE_REFERENCE(CWASTEDlgText);
-
- }
-
-
- /**** C O M M A N D M E T H O D S ****/
-
-
- /******************************************************************************
- DoCommand {OVERRIDE}
-
- Handle application commands
- ******************************************************************************/
-
- void CApp::DoCommand(long theCommand)
-
- {
- switch (theCommand)
- {
-
- // Insert your command cases here
-
- default:
- x_CApp::DoCommand(theCommand);
- break;
- }
- }
-
-
- /******************************************************************************
- GetDocTypeFromDialog
-
- Get the document type from the dialog. If you have multiple
- document types, you must override this function to extract
- the type from the dialog state. (The dialog has been executed
- and OK'd by the user.) If you do not have multiple document
- types, you can remove this function.
- ******************************************************************************/
-
- OSType CApp::GetDocTypeFromDialog(CDialogDirector *dialog)
-
- {
- return 0;
- }
-
- /*****************************************************************************\
- SetUpMenus
- \*****************************************************************************/
-
- void CApp::SetUpMenus(void)
- {
- CApplication::SetUpMenus();
-
- // add the system fonts the standard way
- AddResMenu(GetMHandle(MENUfont), 'FONT');
-
- MenuHandle sizeMenuH = GetMHandle(MENUsize);
-
- // add some sizes
- short numItems = CountMItems(sizeMenuH);
-
- InsMenuItem(sizeMenuH, "\p9", numItems + 1);
- InsMenuItem(sizeMenuH, "\p10", numItems + 2);
- InsMenuItem(sizeMenuH, "\p12", numItems + 3);
- InsMenuItem(sizeMenuH, "\p14", numItems + 4);
- InsMenuItem(sizeMenuH, "\p18", numItems + 5);
- InsMenuItem(sizeMenuH, "\p24", numItems + 6);
-
- // set font, style, and size menus to always be not dimmed
- gBartender->SetDimOption(MENUfont, dimNONE);
- gBartender->SetUnchecking(MENUfont, true);
-
- gBartender->SetDimOption(MENUsize, dimNONE);
- gBartender->SetUnchecking(MENUsize, true);
-
- gBartender->SetDimOption(MENUstyle, dimNONE);
- gBartender->SetUnchecking(MENUstyle, true);
- }
-
- // make TSMSwitchboard
- void CApp::MakeSwitchboard( void)
- {
- if (gSystem.hasAppleEvents && gUsingTSM)
- {
- FailOSErr(WEInstallTSMHandlers());
- }
- itsSwitchboard = (CSwitchboard *)new CTSMSwitchboard();
- itsSwitchboard->InitAppleEvents();
- }
-
- // make TSMDesktop
- void CApp::MakeDesktop(void)
- {
- gDesktop = (CDesktop *)new CTSMDesktop();
- }
-
- static Boolean TSMAvailable(void)
- {
- long response;
-
- return (Gestalt(gestaltTSMgrVersion, &response)==noErr);
- }
-
- /******************************************************************************
- DragAndDropAvailable - returns true if drag and drop is available
- ******************************************************************************/
-
- static Boolean DragAndDropAvailable(void)
- {
- long response;
-
- if (Gestalt(gestaltDragMgrAttr, &response) != noErr) return false;
- if ((response & (1 << gestaltDragMgrPresent)) == 0) return false;
- if ((Ptr)InstallTrackingHandler == 0) return false;
- return true;
- }
-